package vip.xiaozhao.intern.baseUtil.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaozhao.intern.baseUtil.intf.dto.ResponseDO;
import vip.xiaozhao.intern.baseUtil.intf.entity.VV;
import vip.xiaozhao.intern.baseUtil.intf.service.VVService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 大V接口控制器
 */
@RestController
@RequestMapping("/VV")
@Slf4j
public class VVController extends BaseController {

    @Autowired
    private VVService vvService;
    
    /**
     * 根据公司、部门、职位获取大V列表接口
     * 
     * @param companyId 公司ID
     * @param departmentId 部门ID
     * @param positionId 职位ID
     * @return 大V列表
     */
    @PostMapping("/getListByPosition")
    public ResponseDO getVVListByPosition(
            @RequestParam(value = "companyId", required = true) Integer companyId,
            @RequestParam(value = "departmentId", required = true) Integer departmentId,
            @RequestParam(value = "positionId", required = true) Integer positionId,
            HttpServletRequest request) {
        
        log.info("获取大V列表，参数: companyId={}, departmentId={}, positionId={}", 
                 companyId, departmentId, positionId);
        
        // 参数校验
        if (companyId == null || companyId <= 0) {
            return ResponseDO.fail("公司ID不能为空");
        }
        
        if (departmentId == null) {
            return ResponseDO.fail("部门ID不能为空");
        }
        
        if (positionId == null || positionId <= 0) {
            return ResponseDO.fail("职位ID不能为空");
        }
        
        try {
            // 调用Service获取大V列表
            List<VV> vvList = vvService.getVVList(companyId, departmentId, positionId);
            return ResponseDO.success(vvList);
        } catch (Exception e) {
            log.error("获取大V列表异常", e);
            return ResponseDO.fail("获取大V列表失败");
        }
    }
} 